We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon\Forms\Form->render() Wrong number of parameters

Following up on my unsuccessful attemp to combine two forms in a single page, I tried to understand how this works but I still don't get it. The following code is part of vokuro example.

How do I include a form, that is normally access through session/login , in to indexcontroller.php? so instead of clicking on a link to login, I want it to be displayed on the index page. I do not want to copy paste the contents of session controller login action as I want to be able to access session/login also.

I've followed the example on Phalcon\Forms

I set up dependency injector in services.php as:

    $di['forms'] = function() {
    return new Phalcon\Forms\Manager();
    };

then in indexcontroller.php I added:

    $this->forms->set('login', new LoginForm());
    echo $this->forms->get('login')->render();

but I get

    Wrong number of parameters
    #0 C:\wamp\www\vokuro\app\controllers\IndexController.php(33): Phalcon\Forms\Form->render()
    #1 [internal function]: Vokuro\Controllers\IndexController->indexAction()
    #2 [internal function]: Phalcon\Dispatcher->dispatch()
    #3 C:\wamp\www\vokuro\public\index.php(37): Phalcon\Mvc\Application->handle()
    #4 {main}

I tried adding use Phalcon\Mvc\View\Simple; to indexcontroller.php but that didn't help either. I feel like I understand how most of this work but when I attemp to use the example codes in the documentation, nothing works. What am I doing wrong?

If I understand it correctly, the render() function only renders single fields, so you have to use a loop and render each element in the form.

The parameter for render method is the field (attribute) name.